#include <bits/stdc++.h>
// 2025/01/22
// tag: 
// Author: Zhang Muen
using namespace std;

int n, m, tree[1000001];

bool check(int64_t h){
    int64_t s = 0;
    for (int i = 1; i <= n; i++){
        if (tree[i] > h)
            s += tree[i] - h;
        if (s >= m)
            return true;
    }
    return false;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> tree[i];
    sort(tree + 1, tree + n + 1);
    int64_t l = 0, r = 1e5 * 4;
    while (l <= r){
        int mid = (l + r) / 2;
        if (check(mid))
            l = mid + 1;
        else
            r = mid - 1;
    }
    cout << l - 1;
    return 0;
}